//创建fs模块
let fs = require("fs");
if (!fs.existsSync("files")) fs.mkdirSync("files");
let big = fs.openSync("./files/big.txt", "w",);
//写入文本
for(i=1;i<=10;i++){
    //文本写入
    fs.writeSync(big,"嗨嗨嗨，你是老八");
}
fs.closeSync(big);
//创建阅读流
var rs = fs.createReadStream("./files/big.txt", 'utf-8');
var read=fs.readFileSync("./files/big.txt",'utf-8');
var sc=[];
//取到最大的那个值与出现次数
    for(var j=0;j<read.length;j++){
      let str=read.charAt(j);
      if(sc[str]){
        sc[str]++
      }else{
        sc[str]=1;
      }
    }
    let number=0;
    let max='';
    for(var k in sc){
      if(sc[k]>max){
        number=sc[k];
        max=k;
      }
    }
    //输出文本
rs.on("data", (giao) => {
   console.log(giao);
});
//输出结果
rs.on("end", (giao) => {
    console.log('最多的字符是:',max);
    console.log("出现了:"+number+"次")
    console.log("运行结束");
});
//结束